<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>个人存款计算机</title>
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
		<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
		<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<script>
			function calc()
			{
				mon=$("#money").val();
				reg=/^[0-9]{2,5}$/<!--正则表达式-->
				if(!reg.test(mon))
				{
					$("#money").css("border-color","red");
					return;
				}
				else
				{
					$("#money").css("border-color","");
				}
				monNum=parseInt(mon);//类型转换
				year=$("#year option:selected").text();
				if(year=="一年")
				{
					balance=monNum*0.0175*1;
					total=monNum+balance;
				}
				if(year=="二年")
				{
					balance=monNum*0.0225*2;
					total=monNum+balance;
				}
				if(year=="三年")
				{
					balance=monNum*0.0275*3;
					total=monNum+balance;
				}
				if(year=="五年")
				{
					balance=monNum*0.0275*5;
					total=monNum+balance;
				}
				$("#balance").val(balance);
				$("#total").val(total);
				//alert("大家好！");
				//confirm("您确认删除吗？")
			}
		</script>
	</head>
	<body>
		<div style="width:50%;" class="center-block text-center"><!--style="width:50%;"-->
			<table class="table table-bordered">
				<tr class="bg-primarys text-center">
					<td colspan="2">个人存款计算器</td>
				</tr>
				<tr>
					<td>存款金额</td>
					<td>
						<input placeholder="请输入数字" class="form-control" type="text" id="money">
					</td>
				</tr>
				<tr>
					<td>存款期限</td>
					<td>
						<select class="form-control" id="year">
							<option value="0.0175">一年</option>
							<option value="0.0225">二年</option>
							<option value="0.0275">三年</option>
							<option value="0.0275">五年</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>所得利息</td>
					<td>
						<input readonly="readonly" class="form-control" type="text" id="balance">
					</td>
				</tr>
				<tr>
					<td>本息合计</td>
					<td>
						<input readonly="readonly" class="form-control" type="text" id="total">
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<button onclick="calc()" class="btn btn-danger btn-block"> 开始计算</button>
					</td>
				</tr>
			</table>
			开发者：182054409张家豪
		</div>	
	</body>
</html>
